﻿#pragma once
#include "AsEnvironmentBasics.h"

__AS_JY(Update 2023.1.8)
class ADF_EXPORT AsEnvironmentGlobal {
public:
	AsEnvironmentGlobal();

private:
	QMap<QString, AsEnvPointer> mapPointers;

public:
	template <typename _Type>
	void defPointer(const QString& name, _Type* pointer) {
		if (mapPointers.contains(name)) {
			asEnvDebug(QString("Failed to def object (name: %1)").arg(name));
			return;
		}
		mapPointers[name] = pointer;
	}
	template <typename _Type>
	_Type* getPointer(const QString& name) {
		if (!mapPointers.contains(name)) {
			asEnvDebug(QString("Failed to get object (name: %1)").arg(name));
			throw AsException();
		}
		return mapPointers[name];
	}
	template <typename _Type>
	void setPointer(const QString& name, _Type* pointer) {
		if (!mapPointers.contains(name)) {
			asEnvDebug(QString("Failed to set object (name: %1)").arg(name));
			throw AsException();
		}
		mapPointers[name] = pointer;
	}
	template <typename _Type>
	void rmvPointer(const QString& name) {
		if (!mapPointers.contains(name)) {
			asEnvDebug(QString("Failed to rmv object (name: %1)").arg(name));
			throw AsException();
		}
		mapPointers.remove(name);
	}
	


};
